const express = require('express');
const bodyParser = require('body-parser');
const cookieParser = require('cookie-parser');
const cookieSession = require('cookie-session');
const consolidate = require('consolidate');
const multer = require('multer');
const path = require('path');
const static = require('express-static');

var multerObj = multer({dest:'./static/upload/'});

var app = express();

app.listen(8081);

app.set('view engine','html');

app.set('views','./views');

app.engine('html',consolidate.ejs);

app.use(multerObj.any());
app.use(bodyParser.urlencoded({extended:false}));

app.use(cookieParser());
app.use(cookieSession({
    name:'sessionid',
    keys:['djkljk13','125423','bjkdjf'],
    maxAge:20*36000*1000
}))
//处理请求
app.use('/admin',require('./route/admin/index')());


//设置静态文件位置,否则css文件什么的找不到
app.use(express.static(path.join(__dirname, 'static')));
